From: kaf24@firebug.cl.cam.ac.uk Date: Wed, 14 Sep 2005 13:34:14 +0000 (+0000) Subject: Add some sanity check when creating 3-level 1:1 page table X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~16806^2~16^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=458fb4bc122a30e2a440b299165f6835dc862948;p=xen.git Add some sanity check when creating 3-level 1:1 page table in VMX domain builder. - Add check for empty l2e page entry. - Add check for failed vl1tab map. Signed-off-by: Yunhong Jiang Signed-off-by: Asit Mallick --- diff --git a/tools/libxc/xc_vmx_build.c b/tools/libxc/xc_vmx_build.c index a2b21b735a..2efdf289a3 100644 --- a/tools/libxc/xc_vmx_build.c +++ b/tools/libxc/xc_vmx_build.c @@ -169,21 +169,35 @@ static int zap_mmio_range(int xc_handle, u32 dom, l2_pgentry_t *vl2tab; mmio_addr = mmio_range_start & PAGE_MASK; - for (; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE) { + for ( ; mmio_addr < mmio_range_end; mmio_addr += PAGE_SIZE ) + { vl3e = vl3tab[l3_table_offset(mmio_addr)]; - if (vl3e == 0) + if ( vl3e == 0 ) continue; - vl2tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, vl3e >> PAGE_SHIFT); - if (vl2tab == 0) { + + vl2tab = xc_map_foreign_range( + xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, vl3e>>PAGE_SHIFT); + if ( vl2tab == NULL ) + { PERROR("Failed zap MMIO range"); return -1; } + vl2e = vl2tab[l2_table_offset(mmio_addr)]; - if (vl2e == 0) + if ( vl2e == 0 ) + { + munmap(vl2tab, PAGE_SIZE); continue; - vl1tab = xc_map_foreign_range(xc_handle, dom, PAGE_SIZE, - PROT_READ|PROT_WRITE, vl2e >> PAGE_SHIFT); + } + + vl1tab = xc_map_foreign_range( + xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, vl2e>>PAGE_SHIFT); + if ( vl1tab == NULL ) + { + PERROR("Failed zap MMIO range"); + munmap(vl2tab, PAGE_SIZE); + return -1; + } vl1tab[l1_table_offset(mmio_addr)] = 0; munmap(vl2tab, PAGE_SIZE);